package com.ts.mapper.achievement;

import com.ts.entity.OtherResearch;
import org.apache.ibatis.annotations.*;

@Mapper
public interface OtherResearchMapper {

    /**
     * 存入一条其他研究数据并且主键返回
     * */
    @Insert("INSERT INTO `tianshi-college-teacher-system-test`.ts_other_research (" +
            "achievement_type, research_name, research_number, host_or_participant, position_rank, " +
            "research_category, subject_category, cooperation_form, project_type, vertical_project_level, " +
            "total_funding, school_funding, start_time, end_time, research_source, remark, evidence_material, " +
            "create_by, create_time, update_by, update_time" +
            ") VALUES (" +
            "#{achievementType}, #{researchName}, #{researchNumber}, #{hostOrParticipant}, #{positionRank}, " +
            "#{researchCategory}, #{subjectCategory}, #{cooperationForm}, #{projectType}, #{verticalProjectLevel}, " +
            "#{totalFunding}, #{schoolFunding}, #{startTime}, #{endTime}, #{researchSource}, #{remark}, #{evidenceMaterial}, " +
            "#{createBy}, #{createTime}, #{updateBy}, #{updateTime}" +
            ")")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    void save(OtherResearch otherResearch);
    /**
     * 根据ID查询其他研究
     */
    @Select("SELECT * FROM `tianshi-college-teacher-system-test`.ts_other_research WHERE id = #{id}")
    OtherResearch getById(long id);
    /**
     * * 更新其他研究
     */
    @Update("UPDATE `tianshi-college-teacher-system-test`.ts_other_research SET " +
            "achievement_type = #{achievementType}, " +
            "research_name = #{researchName}, " +
            "research_number = #{researchNumber}, " +
            "host_or_participant = #{hostOrParticipant}, " +
            "position_rank = #{positionRank}, " +
            "research_category = #{researchCategory}, " +
            "subject_category = #{subjectCategory}, " +
            "cooperation_form = #{cooperationForm}, " +
            "project_type = #{projectType}, " +
            "vertical_project_level = #{verticalProjectLevel}, " +
            "total_funding = #{totalFunding}, " +
            "school_funding = #{schoolFunding}, " +
            "start_time = #{startTime}, " +
            "end_time = #{endTime}, " +
            "research_source = #{researchSource}, " +
            "remark = #{remark}, " +
            "evidence_material = #{evidenceMaterial}, " +
            "update_by = #{updateBy}, " +
            "update_time = #{updateTime} " +
            "WHERE id = #{id}")
    void update(OtherResearch otherResearch);

    /**
     * 根据ID删除其他研究
     */
    @Delete("DELETE FROM `tianshi-college-teacher-system-test`.ts_other_research WHERE id = #{id}")
    void delete(Long id);
}

